package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Calendar;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.gdms.model.User;
import com.zr.gdms.service.CourseService;
import com.zr.gdms.serviceimpl.CourseServiceImpl;


public class addAppControllerZYH extends HttpServlet{
	  CourseService cs = new CourseServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		HttpSession session = req.getSession();
		String appcontent = req.getParameter("acontent");
		User u = (User) session.getAttribute("user");
		int tid = cs.findTidByUid(u.getUid());
		int month=6,date =9 ;//设置6月9日24:00为上传截止时间
		Calendar c = Calendar.getInstance();
		int m = c.get(Calendar.MONTH)+1;
		int d = c.get(Calendar.DATE);
		PrintWriter pw = resp.getWriter();
		if(m<=month && d<=date){
			boolean bl = cs.AddCourseByTime("上传课题", appcontent, tid,"审核中");
			if(bl==true){
				pw.write("1");
			}
			}else{
				pw.write("0");
			}
		pw.flush();
		pw.close();
	}
}
